<?php

/**
 * This is the model class for table "xyh_activity_link_signup".
 *
 * The followings are the available columns in table 'xyh_activity_link_signup':
 * @property string $activity_id
 * @property string $address
 * @property string $contacts
 * @property string $tel
 * @property string $content
 * @property string $signup_start_time
 * @property string $signup_end_time
 * @property string $lottery_start_time
 * @property string $lottery_end_time
 * @property string $is_need_checkin
 */
class ActivityLinkSignup extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ActivityLinkSignup the static model class
	 */
    
        //public  $is_need_lottery;
       //public  $is_need_signup;


        public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'xyh_activity_link_signup';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('content', 'required',  'message'=>'请填写活动内容!'),
			//array('activity_id, signup_start_time, signup_end_time, lottery_start_time, lottery_end_time', 'length', 'max'=>10),
			array('address, contacts, tel', 'length', 'max'=>255),
			array('is_need_checkin,is_need_lottery,is_need_signup,', 'numerical'),
                        array('address','required','message'=>'请填写活动地址!'),
                        array('signup_start_time,signup_end_time,lottery_start_time,lottery_end_time','safe'),
                       // array('signup_start_time','required','message'=>'报名时间不能为空!'),
                       // array('signup_end_time','required','message'=>'报名时间不能为空!'),
                       array('activity_id','required'),
                      
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('activity_id, address, contacts, tel, content, signup_start_time, signup_end_time, lottery_start_time, lottery_end_time, is_need_checkin', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
                     'Activity' => array(self::HAS_MANY, 'Activity', 'activity_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'activity_id' => 'Activity',
			'address' => 'Address',
			'contacts' => 'Contacts',
			'tel' => 'Tel',
			'content' => 'Content',
			'signup_start_time' => 'Signup Start Time',
			'signup_end_time' => 'Signup End Time',
			'lottery_start_time' => 'Lottery Start Time',
			'lottery_end_time' => 'Lottery End Time',
			'is_need_checkin' => '是否签到',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('activity_id',$this->activity_id,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('contacts',$this->contacts,true);
		$criteria->compare('tel',$this->tel,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('signup_start_time',$this->signup_start_time,true);
		$criteria->compare('signup_end_time',$this->signup_end_time,true);
		$criteria->compare('lottery_start_time',$this->lottery_start_time,true);
		$criteria->compare('lottery_end_time',$this->lottery_end_time,true);
		$criteria->compare('is_need_checkin',$this->is_need_checkin,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}